package com.mgq.java8.lambda;

import java.util.ArrayList;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.Function;

/**
 * <b>功能：</b>函数式接口测试<br>
 * <b>Copyright mgq</b>
 * <li>版本&nbsp;&nbsp;&nbsp;&nbsp;修改日期&nbsp;&nbsp;&nbsp;&nbsp;部　　门&nbsp;&nbsp;&nbsp;&nbsp;作　者&nbsp;&nbsp;&nbsp;&nbsp;变更内容</li><hr>
 * <li>v1.0&nbsp;&nbsp;&nbsp;&nbsp;20220412&nbsp;&nbsp;营业后台&nbsp;&nbsp;&nbsp;&nbsp;马广奇&nbsp;&nbsp;&nbsp;&nbsp;创建类</li>
 * <br><br>
 *
 * @author 马广奇
 * @version 2022-04-12 20:44
 */
public class FunctionTest {
    public static void test() {
        Function<String, Boolean> function = String::isBlank;
        Boolean isBlank = function.apply("sss");
        System.out.println(isBlank);
        BiFunction<String, Integer, List<Integer>> biFunction = (s, integer) -> {
            List<Integer> list = new ArrayList<>();
            list.add(s.length());
            list.add(integer);
            return list;
        };
        List<Integer> hello = biFunction.apply("hello world", 222);
        //java8 提供的function
        //IntFunction<R>,
        //IntToDoubleFunction,
        //IntToLongFunction,
        //LongFunction<R>,
        //LongToDoubleFunction,
        //LongToIntFunction,
        //DoubleFunction<R>,
        //ToIntFunction<T>,
        //ToDoubleFunction<T>,
        //ToLongFunction<T>
        hello.forEach(System.out::println);
    }

    public static void main(String[] args) {
        test();
    }
}
